/**
 * @Author: Shann
 * @LastEditors: Shann
 * @Date: 2021-07-23 14:10:33
 * @LastEditTime: 2021-07-26 18:54:56
 * @Copyright: Copyright 2021-2021, all rights reserved. Essa.cn
 */

class Modal {
    props = {
        visible: Boolean,
        title: String,
        okText: String,
        cancelText: String,
        onOk: Function,
        onCancel: Function,
    };

    state = {
        okText: this.props.okText || "确定",
        cancelText: this.props.cancelText || "取消",
    };

    /**
     * 构造方法
     */
    constructor() {
        // 监听
        scope.$watch("visible", function (newValue) {
            if ($("#myModal").length !== 0) {
                $("#myModal").modal(newValue ? "show" : "hide");
                $("#myModal").on("hidden.bs.modal", function (e) {
                    $timeout(() => {
                        this.props.onCancel();
                    }, 0);
                });
            }
        });
    }
}
